<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/mask.js"></script>
<style type="text/css">
.login-times{
	margin:10px;
	color: #333;
	font-family: '微软雅黑';
	font-size: 13px;
}
.login-times li{
	padding: 10px 0;
	border-bottom: 1px solid #ddd;
}
.login-times li strong{
	padding: 0 5px;
	font-weight: bold;
}
.login-times li span{
	padding: 0 5px;
	color: #e30000;
	font-weight: bold;
}
.kv-item label{
	width: 130px;
	float:left;
}

</style>
<title>问卷查看</title>
</head>

<body>
<div id="mask" class="mask"></div>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>问卷查看</h2>
            </div>
			<div class="subfiled-content">
				 <form class="saper-form" id="dataForm">
				 <div class="kv-item clearfix">
                    <label>问卷名称：${wenjuan.wenjuanName}</label>
                    <label>科室：${wenjuan.department.departmentName}</label>   
	             </div>
	             <ul class="login-times">
	             	<c:forEach items="${wenjuan.questions}" var="questions" varStatus="i">
                    	<li>
                   			问题${i.index+1}:<strong>${questions.question}</strong><br/>
                   			<input type="hidden" name="questionId" value="${questions.id}"/>
                   			<c:if test="${questions.datiType == 1}">
                   				 <c:forEach items="${questions.answerList}" var="answer">
                   				 	<input type="checkbox" name="answers${questions.id}" value="${answer.label}"/>${answer.labelVal} &nbsp;&nbsp;&nbsp;&nbsp;  
                   				 </c:forEach>
                   				 
                   			</c:if>
                   			<c:if test="${questions.datiType == 2}">
                   				 <c:forEach items="${questions.answerList}" var="answer">
                   				 	<input type="radio" name="answers${questions.id}" value="${answer.label}"/>${answer.labelVal} &nbsp;&nbsp;&nbsp;&nbsp; 
                   				 </c:forEach>
                   			</c:if>
                    	</li>
                    </c:forEach>
                </ul>
                <div class="buttons">
	                    <a href="javascript:;" class="sapar-btn sapar-btn-recom">提交问卷</a>
	                    <input name="id" type="hidden" value="${wenjuan.id}">
	                </div>
                </form>
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>
    
</body>

<script type="text/javascript">
$(function(){
	$(".sapar-btn-recom").click(function(){
		 var btn = true;
		 $(".txt_required").each(function(){
			 if($(this).val() == ''){
				 btn = false;
				 layer.msg("必填项不为空");
				 return false;
			 }
		 });
		 if(btn){
			 showMask();
			 $.ajax({
	             type: "POST",
	             url:"${ctx}/wenjuan/wenjuanSave.do",
	             data:$('#dataForm').serialize(),// 你的formid
	             error: function(request) {
	            	 	layer.alert("网络故障，请稍后再试!");
	             },
	             success: function(data) {
	            	 $("#mask").hide();
	 	           	if(data.status=="true"){
		 	           	layer.alert("保存成功", function(){
		 	           		window.location.href="${ctx}/wenjuan/wenjuanList.do";
	           		    });
	 	           	}else{
	 	           		 layer.msg(data.msg);
	 	           	}
	             }
	         }); 
		 }
	});
});
</script>
</html>